home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume90
/
comm
/
dnet
/
dnet_213
/
part03
< prev
next >
Wrap
Internet Message Format
|
1990-03-27
|
64KB
Path: xanth!cs.odu.edu!Amiga-Request
From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
Newsgroups: comp.sources.amiga
Subject: v90i120: DNet 2.13 - multiple windows/file transfers over a serial line, Part03/08
Message-ID: <11940@xanth.cs.odu.edu>
Date: 27 Mar 90 01:19:14 GMT
Sender: tadguy@cs.odu.edu
Reply-To: dales%teksce.sce.tek.com@RELAY.CS.NET
Lines: 2477
Approved: tadguy@cs.odu.edu (Tad Guy)
X-Mail-Submissions-To: Amiga@cs.odu.edu
X-Post-Discussions-To: comp.sys.amiga
Submitted-by: dales%teksce.sce.tek.com@RELAY.CS.NET
Posting-number: Volume 90, Issue 120
Archive-name: comm/dnet/dnet-2.13/part03
#!/bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 3 (of 8)."
# Contents: amiga/INSTALLATION amiga/README amiga/client/putfiles.c
# amiga/dnet/ipc.c amiga/doc/dnetlib.doc amiga/doshand/dos.h
# amiga/server/scopy.c unix/README unix/client/putfiles.c
# unix/dnet/internal.c unix/doc/dnetlib.doc unix/server/sgcopy.c
# Wrapped by tadguy@xanth on Mon Mar 26 20:15:11 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'amiga/INSTALLATION' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/INSTALLATION'\"
else
echo shar: Extracting \"'amiga/INSTALLATION'\" \(4800 characters\)
sed "s/^X//" >'amiga/INSTALLATION' <<'END_OF_FILE'
X
X BASIC INSTALLATION AND RUN
X
X --- AMIGA INSTALL ---
X
X The 1.3 (or greater) serial.device must be used
X
X The following must exist in L: and be mounted.
X
X L:NULL-HANDLER
X L:DPIPE-HANDLER (only required if you use the remote cli server)
X
X
X The following must exist in S:
X
X S:DNET.SERVERS
X S:DNET.CONFIG
X
X You may have to modify S:DNET.CONFIG to appropriately handle the
X CONNECT message of your modem.
X
X If you do not have a logical DNET: assignment where the server
X executables are in DNET:AMIGA/BIN then you must modify S:DNET.SERVERS
X to point to the appropriate server executables.
X
X Make sure your path includes DNET:AMIGA/BIN or wherever you have placed
X the client executables. This is required so DNET knows how to find
X the FTERM executable when starting up the automatic FTERM.
X
X
X --- UNIX INSTALL ---
X
X You must set the enviroment variable DNETDIR in your .cshrc to an
X initially empty directory (i.e. create an unobstrusive directory). This
X directory will hold the UNIX domain sockets DNet uses to communicate.
X Security on the UNIX side is solely determined by who has access to this
X directory. For example:
X
X Extract the distribution.
X
X % cd dnet
X % MAKE (you may have to chmod this +x, this is a shell script)
X
X This compiles the code. Binaries should exist in dnet/unix/bin. If
X you have problems not easily fixed please email me. Note that the
X source only compiles on systems compatible with BSD 4.3 . The code
X should compile on Suns running 3.5 but does not appear to run on
X suns running 4.0 (??). The code compiles and runs on Dynix system
X 3.0.12 or higher. The code has been found to compile pretty well
X on Sys V *with* berkeley socket extensions.
X
X % cd ~
X % mkdir .DNET
X % vi .cshrc (and add the following line)
X setenv DNETDIR ~/.DNET/
X % source .cshrc (make sure the change is made part of your shell)
X
X NOTE the trailing slash (/) on the DNETDIR enviroment variable. Do
X not forget this.
X
X Copy the UNIX dnet.servers file into ~/.DNET (or whatever directory
X you had defined from DNETDIR.
X
X
X ******** RUN *******
X
X Sequence of events (basic options, see dnet.doc for other options).
X 2400 baud is assumed in the below example, simply change where it
X applies if running at a different baud rate.
X
X (1) on amiga
X
X (i) The connection to your system is 7 bits and parity is
X ignored.
X
X 1> run dnet -b2400 -P0 -Z0
X
X (ii) The connection to your system is 7 bits even parity and
X parity is enforced.
X
X 1> run DNET -b2400 -P0 -Z2
X
X (iii) The connection to your system is 8 bits and supports raw
X 8 bit transfers (no parity).
X
X 1> run DNET -b2400 -P0 -Z0 -m0
X
X Other combinations may apply, see doc/dnet.doc for details. The
X -P option selects the protocol and -Z selects parity.
X
X (2) From small DNet window now open on the amiga.
X
X Use the AT command set or otherwise instruct your modem to
X dial your system. For hard connections where no modem exists
X this is not necessary, though with some hard connections you
X will need to use the SEND-BREAK menu option to send a line
X break to get a system prompt.
X
X Log into your UNIX account
X
X (3) From the UNIX prompt: (be sure the DNETDIR enviroment variable
X is set appropriately and your path contains the dnet executable
X and clients.
X
X (i) The connection to your system is 7 bits and parity is ignored,
X
X % dnet
X
X (ii) The connection to your system is 7 bits even parity and parity
X is enforced
X
X % stty -odd
X % dnet
X
X (iii) The connection to your system is 8 bits
X
X % dnet -m0
X
X (4) At this point the small dnet window should disappear. After a
X few seconds an FTERM window should open and after another small
X delay give you a shell prompt.
X
X Congratulations, you are running DNet.
X
X Now you may do all sorts of things. You may run other FTERM
X windows from your amiga (1> run fterm) and therefore have
X several shell windows... you can run file transfer clients
X (putfiles and getfiles) on either the amiga or unix sides, etc...
X read the documentation in the doc directory for more info.
X
X
X SHUTTING DOWN
X
X Logging out of an FTERM window does not kill DNet. To kill DNet
X use the 'quitdnet' command on the Amiga side. This should kill all
X connections and bring back the original small dnet window with the
X original shell prompt from which you should be able to log out
X normally. If you are unable to get the original shell prompt in
X the small dnet window you may have to restart the protocol (menu
X option) and try 'quitdnet' again. If all else fails simply hanging
X up the modem should work (in which case you BREAK the dnet process
X on the Amiga side).
X
X
X
X
END_OF_FILE
if test 4800 -ne `wc -c <'amiga/INSTALLATION'`; then
echo shar: \"'amiga/INSTALLATION'\" unpacked with wrong size!
fi
# end of 'amiga/INSTALLATION'
fi
if test -f 'amiga/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/README'\"
else
echo shar: Extracting \"'amiga/README'\" \(5722 characters\)
sed "s/^X//" >'amiga/README' <<'END_OF_FILE'
X
X DNET V2.10
X 27 November 1989
X
X NEW THIS RELEASE: 7 bit support.
X
X DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved
X
X Matthew Dillon
X 891 Regal Rd
X Berkeley, Ca. 94708
X USA
X
X ...!ihnp4!ucbvax!dillon USENET
X dillon@ucbvax.Berkeley.edu ARPANET
X ucbvax.berkeley.edu pub/amiga ARPANET-FTP
X
X WHAT IS DNET
X
X DNet is a link protocol and should properly be called DLink, but
X the name DNet stuck and so it will stay. DNet allows one to connect two
X amigas together and run multiple connections between them. For example,
Xyou can open a talk window or two or three and be doing an upload and be
Xdoing a download all at the same time.
X
X Currently, DNet can be used to connect two Amiga's together or
Xan Amiga to a 4.2BSD/4.3BSD compatible UNIX.
X
X ** AN 8 BIT PATH IS NO LONGER REQUIRED. DNET WILL NOW RUN OVER
X 7 BIT PATHS. (TAB,FF,CR,LF, 0x20-0x7F).
X
X
X INSTALLING DNET ON YOUR AMIGA
X
X (1) ## REMOVED, was copy dres.library to libs:. no longer required.
X
X (2) copy the DNet binary and all client and server program to
X somewhere accessable on your path.
X
X (3) copy s/dnet.servers to s:
X
X * modify s:dnet.servers so all server paths point to whereever
X you stuck the servers
X
X (4) copy s/dnet.config to s:
X
X * you may have to modify s:dnet.config too ... look into the
X DOC directory for more information.
X
X CALL A FRIEND WHO HAS GOT DNET INSTALLED
X
X 1> RUN DNET -X -8 -b1200
X
X NOTE: -h0 option in previous versions is now the default. Use -h1
X to *enable* carrier detect checking.
X
X 7 bit mode is now the default. Use -m0 if you have an 8 bit
X connection and want to take advantage of it.
X
X PARITY NOTE: If your system forces parity you specify the
X appropriate parity option with the -Z switch,
X refer to dnet.doc
X
X warning: The defaults for -X (manual mode) in S:DNET.CONFIG
X turn off security. Please read documentation in the doc directory
X for more information. This README file is only intended to get
X you up and running. The above line also sets the baud to 1200...
X the idea is you set it to what is proper for your modem. Again,
X read DOC/DNET.DOC for more options and information.
X
X A small DNET window should appear from which you can dialup your
X friend's amiga. On CONNECT, DNET should automatically adjust the
X baud rate. It may be necessary to modify S:DNET.CONFIG in this
X regard (read the docs!)
X
X After connecting, executing the START DNET menu option from either
X end will start the protocol. The small dnet window should go away
X and DNET should attempt to run the FTERM client program, which
X connects to an STERM server program on the other end. Your friend's
X amiga will do the same.
X
X If all goes ok, it should flash the window size in the title bar
X and you can type. If not, the window will go away and an error
X message will be printed out in your CLI: "unable to connect".
X
X WARNING: Even if there are no windows open (no clients active),
X DNet is still running!!!! us the CLI BREAK command to kill DNet
X and give you back the initial DNet window, from which you can
X hit the close-window gadget.
X
X breaking the DNet protocol will kill any active clients.
X
X
X SERVERS AND CLIENTS
X
X
X DNet has a notion of servers and clients. That is, you run the
Xprotocol as described above, then run other external programs that talk
Xto the core program "DNet". These other external programs "FTerm",
X"GetFiles", "PutFiles", etc... obtain virtual connections to special
Xserver programs on the remote machine.
X
X Thus, when you started the protocol above DNet automatically
Xran the FTERM client... you can run as many FTERMs as you have memory
Xfor (well, actually, DNet is limited to 64 simultanious channels). When
Xa client program such as FTERM is run on computer A, it causes the
Xappropriate server program (STERM in this case) to automatically be run
Xon computer B. The client and server need some way to rendezvous, and they
Xdo this by giving the same PORT NUMBER to the protocol driver.
X
X This is what the S:DNET.SERVERS file is ... when you run a client
Xon computer A it asks for server #<blah> (e.g. 8195 for an FTERM) on the
Xremote machine. computer B (the remote machine) looks up 8195 in the
XS:DNET.SERVERS file, finds the path to the server in question, and runs it
Xautomatically.
X
X PORT CLIENT SERVER PURPOSE
X
X 8192 PutFiles SCopy send files to remote computer
X 8195 FTerm STerm open a talk window on both computers
X 8196 CLITerm SCli remote-CLI (actually newshell)
X 8197 LoadAv ------ Load-Average window (when running DNet
X to a UNIX machine)
X 8198 ------ SPrint printer server
X 8199 ------ SPasswd password server. Used to gain security
X access for auto-answer callups
X 8201 GetFiles SGCopy download files from remote computer
X
X NOTE: FTERM may be used to connect to arbitrary ports that otherwise have
X no associated client. see the docs for FTERM.
X
X READ THE DOCS FOR EACH OF THESE CLIENTS
X
X SECURITY
X
X Read DOC/DNET.DOC and documentation for each client/server. DNet
X implements various levels of security. This is intended for BBS
X support but I have not finished my DNet-BBS program yet. The security
X is still there, however.
X
X One example: If the DNET_READ security option (env: var is set
X automatically from S:DNET.CONFIG depending on the option you give
X DNET when you first run it) is anything less than 9, the SGCopy
X server for GetFiles will only allow uploading from directories with
X their comment field set a certain way. That is, you can control
X exactly what you allow other people to download.
X
X
X
END_OF_FILE
if test 5722 -ne `wc -c <'amiga/README'`; then
echo shar: \"'amiga/README'\" unpacked with wrong size!
fi
# end of 'amiga/README'
fi
if test -f 'amiga/client/putfiles.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/client/putfiles.c'\"
else
echo shar: Extracting \"'amiga/client/putfiles.c'\" \(3861 characters\)
sed "s/^X//" >'amiga/client/putfiles.c' <<'END_OF_FILE'
X
X/*
X * PUTFILES.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * Upload one or more files or directories to the remote host
X */
X
X#include "defs.h"
X
Xchar Buf[1024];
X
Xint putname ARGS((void *, char *));
Xint putfile ARGS((void *, char *, char *));
Xint writehdr ARGS((void *, ubyte, char *, long));
X
Xvoid main ARGS((int, char **));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
Xmain(ac,av)
Xchar *av[];
X{
X void *chan;
X short i;
X char fn = 0;
X char *host = NULL;
X char *dir = NULL;
X
X printf("PutFiles V%s%s\n", VERSION, PUTFILES_VERSION);
X ac = DoOption(ac, av, "N%sd%s", &host, &dir);
X
X onbreak(brk);
X if (ac <= 1) {
X puts("putfiles [-Nnetid] [-dremotedir] file/dir file/dir ....");
X exit(1);
X }
X chan = DOpen(host, PORT_FILECOPY, -80, 126);
X if (!chan) {
X puts("Unable to connect");
X exit(1);
X }
X DRead(chan, &fn, 1);
X if (fn == 'S') {
X puts("Remote Server Permission Denied");
X DClose(chan);
X exit(1);
X }
X if (fn != 'Y') {
X puts("Remote Server Software Error");
X DClose(chan);
X exit(1);
X }
X if (dir) {
X if (writehdr(chan, 'C', dir, 0) != 'Y') {
X printf("Remote directory unavailable: %s\n", dir);
X goto fail;
X }
X }
X for (i = 1; i < ac; ++i) {
X if (putname(chan, av[i]) < 0)
X break;
X }
Xfail:
X printf("\nclosing... ");
X fflush(stdout);
X DClose(chan);
X puts("done");
X}
X
Xint
Xputname(chan, file)
Xvoid *chan;
Xchar *file;
X{
X long lock = Lock(file, SHARED_LOCK);
X long dirl;
X int ret = 1;
X FIB *fib = (FIB *)malloc(sizeof(FIB));
X
X printf("%-20s ", file);
X if (lock == NULL || !Examine(lock, fib)) {
X if (lock)
X UnLock(lock);
X free(fib);
X puts("NOT FOUND");
X return(1);
X }
X if (fib->fib_DirEntryType > 0) {
X char *dirname = (fib->fib_FileName[0]) ? fib->fib_FileName : "ram";
X puts("DIR");
X dirl = (long)CurrentDir(lock);
X if (writehdr(chan, 'X', dirname, 0) != 'Y') {
X puts("Remote unable to make directory");
X goto f1;
X }
X while (ExNext(lock, fib)) {
X if (putname(chan, fib->fib_FileName) < 0) {
X ret = -1;
X goto f1;
X }
X }
X writehdr(chan, 'Y', "?", 0);
Xf1:
X UnLock(CurrentDir(dirl));
X } else {
X UnLock(lock);
X ret = putfile(chan, file, fib->fib_FileName);
X }
X free(fib);
X return(ret);
X}
X
Xint
Xputfile(chan, file, stripedname)
Xvoid *chan;
Xchar *file;
Xchar *stripedname;
X{
X long fh = (long)Open(file, 1005);
X long n, r, len;
X long ttl = 0;
X char co;
X
X fflush(stdout);
X if (fh == NULL) {
X puts("FILE NOT FOUND");
X return(0);
X }
X Seek(fh, 0, 1); /* get length */
X len = ttl = Seek(fh, 0, -1);
X if (writehdr(chan, 'W', stripedname, len) != 'Y') {
X puts("REMOTE UNABLE TO ACCEPT FILE");
X Close(fh);
X return(0);
X }
X printf("%6ld/%-6ld", ttl - len, ttl);
X while (len) {
X fflush(stdout);
X r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
X n = Read(fh, Buf, r);
X if (n != r) {
X puts("Local File error");
X Close(fh);
X return(-1);
X }
X if (DWrite(chan, Buf, n) != n) {
X puts("Remote error");
X Close(fh);
X return(-1);
X }
X if (SetSignal(0,0) & (SIGBREAKF_CTRL_C|SIGBREAKF_CTRL_D)) {
X puts("\nBreak");
X Close(fh);
X return(-1);
X }
X len -= n;
X printf("\010\010\010\010\010\010\010\010\010\010\010\010\010");
X printf("%6ld/%-6ld", ttl - len, ttl);
X }
X Close(fh);
X printf("Queued, waiting...");
X fflush(stdout);
X DRead(chan, &co, 1);
X if (co != 'Y') {
X puts("Remote Server Software Error");
X return(-1);
X }
X puts(" OK");
X return(0);
X}
X
Xint
Xwritehdr(chan, c, name, len)
Xvoid *chan;
Xunsigned char c;
Xchar *name;
Xlong len;
X{
X if (DWrite(chan, &c, 1) != 1)
X return(-1);
X c = strlen(name) + 1;
X if (DWrite(chan, &c, 1) != 1)
X return(-1);
X if (DWrite(chan, name, c) != c)
X return(-1);
X if (DWrite(chan, &len, 4) != 4)
X return(-1);
X if (DRead(chan, &c, 1) == 1)
X return((int)c);
X return(-1);
X}
X
END_OF_FILE
if test 3861 -ne `wc -c <'amiga/client/putfiles.c'`; then
echo shar: \"'amiga/client/putfiles.c'\" unpacked with wrong size!
fi
# end of 'amiga/client/putfiles.c'
fi
if test -f 'amiga/dnet/ipc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/dnet/ipc.c'\"
else
echo shar: Extracting \"'amiga/dnet/ipc.c'\" \(4430 characters\)
sed "s/^X//" >'amiga/dnet/ipc.c' <<'END_OF_FILE'
X
X/*
X * IPC.C
X *
X * Handle IPC messages
X *
X * NOTE: Only an explicit disconnect command will drop DTR, or when
X * the serial.device is closed.
X */
X
Xstatic int dummy;
X
X#ifdef NOTDEF
X
X#include "dnet.h"
X#include <local/ipc.h>
X
X#define IPCMDS struct _IPCMDS
X
Xvoid do_online(), do_offline(), do_stat(), do_quit(), do_disconnect();
Xvoid do_state();
Xvoid do_recvon(), do_recvoff(), do_serialon(), do_serialoff();
Xvoid do_baud();
Xvoid do_getidle(), do_getconnect(), do_setidlealert(), do_setconnectalert();
Xvoid do_lessconnect(), do_resetconnect(), do_resetidle();
X
XIPCMDS {
X short args;
X char *name;
X void (*func)();
X};
X
XIPCMDS IPCmds[] = {
X 0, "online" , do_online,
X 0, "offline", do_offline,
X 0, "stat", do_stat,
X 0, "quit", do_quit,
X 0, "disconnect", do_disconnect,
X 0, "state", do_state,
X 0, "recvon", do_recvon,
X 0, "recvoff", do_recvoff,
X 0, "serialon", do_serialon,
X 0, "serialoff", do_serialoff,
X 1, "baud", do_baud,
X
X 0, "getidle", do_getidle,
X 0, "getconn", do_getconnect,
X 2, "setidlealert", do_setidlealert,
X 2, "setconnalert", do_setconnectalert,
X 1, "lessconn", do_lessconnect,
X 0, "resetconn", do_resetconnect,
X 0, "resetidle", do_resetidle
X};
X
Xhandle_ipc()
X{
X IPCMSG *msg;
X char *ptr;
X
X while (msg = GetMsg(IPCPort)) {
X long error = IF_ERROR;
X char **av = NULL;
X short ac = 0;
X short i;
X char *buf = NULL;
X long len = 0;
X
X if (ptr = (char *)msg->TBuf) {
X short networknum = atoi(ptr);
X if (networknum == NetworkNum) {
X while (*ptr++);
X ac = ParseCmd(ptr, &av, NULL, NULL, &error, NULL);
X } else {
X error = IF_NOTFND;
X }
X }
X for (i = 0; i < ac;) {
X IPCMDS *cmds;
X
X for (cmds = IPCmds; cmds != ARYEND(IPCmds); ++cmds) {
X if (strcmp(av[i], cmds->name) == 0)
X break;
X }
X if (cmds == ARYEND(IPCmds)) {
X error = IF_ERROR;
X break;
X }
X if (i + cmds->args >= ac) {
X error = IF_ERROR;
X break;
X }
X error = 0;
X (*cmds->func)(av + i, &buf, &len);
X i += cmds->args + 1;
X }
X if (av)
X FreeParseCmd(av);
X ReplyIPC(msg, buf, len, error);
X }
X}
X
Xvoid
Xdo_online()
X{
X OnLine = 1;
X}
X
Xvoid
Xdo_offline()
X{
X OnLine = 0; /* Take DNet off line */
X}
X
Xvoid
Xdo_disconnect()
X{
X OnLine = 0; /* Take DNet off line */
X DropDTR(); /* and (temp) drop DTR */
X}
X
Xvoid
Xdo_quit()
X{
X Quit = 1; /* Quit out of dnet */
X}
X
Xvoid
Xdo_stat(av, pbuf, plen)
Xchar **pbuf;
Xlong *plen;
X{
X char buf[256];
X char *ptr = buf;
X
X sprintf(ptr, " Bytes Packets Errors\n");
X ptr += strlen(ptr);
X sprintf(ptr, "OUT: %8ld %8ld %8ld\n", BytesOut, PacketsOut, PacketsResent);
X ptr += strlen(ptr);
X sprintf(ptr, "IN : %8ld %8ld %8ld\n", BytesIn, PacketsIn, PacketsNakd);
X ptr += strlen(ptr);
X sprintf(ptr, "Garbage Bytes In: %ld\n", GarbageIn);
X ptr += strlen(ptr);
X if (ptr - buf > sizeof(buf))
X dneterror("do_stat: buffer overrun");
X AllocAppend(pbuf, plen, buf, strlen(buf)+1);
X}
X
X/*
X * Return machine state (ascii)
X *
X * s iiii:ii oooo:oo (s = 0/1 1=protrunning
X * i = idle time hrs:min
X * o = online time hrs:min
X */
X
Xvoid
Xdo_state()
X{
X
X}
X
XAllocAppend(pbuf, plen, buf, len)
Xchar **pbuf;
Xlong *plen;
Xchar *buf;
Xlong len;
X{
X char *new;
X if (*pbuf) {
X new = malloc(*plen + len);
X BMov(*pbuf, new, *plen);
X free(*pbuf);
X *pbuf = new;
X new += *plen;
X } else {
X *pbuf = new = malloc(len);
X }
X BMov(buf, new, len);
X *plen += len;
X}
X
Xvoid
Xdo_recvon()
X{
X NetRecvOn();
X}
X
Xvoid
Xdo_recvoff()
X{
X NetRecvOff();
X}
X
Xvoid
Xdo_serialon()
X{
X NetSerialOn();
X}
X
Xvoid
Xdo_serialoff()
X{
X NetSerialOff();
X}
X
Xvoid
Xdo_baud(av)
Xchar **av;
X{
X long baud = atoi(av[1]);
X if (baud) {
X Baud = baud;
X SetBaudRate(baud);
X }
X}
X
Xvoid
Xdo_getidle(av, pbuf, plen)
Xchar **av;
Xchar **pbuf;
Xlong *plen;
X{
X char buf[32];
X sprintf(buf, "%ld", GetIdle());
X AllocAppend(pbuf, plen, buf, strlen(buf)+1);
X}
X
Xvoid
Xdo_getconnect(av, pbuf, plen)
Xchar **av;
Xchar **pbuf;
Xlong *plen;
X{
X char buf[32];
X sprintf(buf, "%ld", GetConnect());
X AllocAppend(pbuf, plen, buf, strlen(buf)+1);
X}
X
Xvoid
Xdo_setidlealert(av)
Xchar **av;
X{
X SetIdleAlert(atoi(av[1]), av[2]);
X}
X
Xvoid
Xdo_setconnectalert(av)
Xchar **av;
X{
X SetConnectAlert(atoi(av[1]), av[2]);
X}
X
Xvoid
Xdo_lessconnect(av)
Xchar **av;
X{
X LessConnect(atoi(av[1]));
X}
X
Xvoid
Xdo_resetconnect()
X{
X ResetConnect();
X}
X
Xvoid
Xdo_resetidle()
X{
X ResetIdle();
X}
X
X#endif
X
X
END_OF_FILE
if test 4430 -ne `wc -c <'amiga/dnet/ipc.c'`; then
echo shar: \"'amiga/dnet/ipc.c'\" unpacked with wrong size!
fi
# end of 'amiga/dnet/ipc.c'
fi
if test -f 'amiga/doc/dnetlib.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/doc/dnetlib.doc'\"
else
echo shar: Extracting \"'amiga/doc/dnetlib.doc'\" \(5169 characters\)
sed "s/^X//" >'amiga/doc/dnetlib.doc' <<'END_OF_FILE'
X
X DNET LINK LIBRARY
X
X Link with your server's and client programs.
X
X
X listenport = DListen(port#) listen for connections
X chanport = DAccept(listenport) accept a new connection
X DNAAccept(listenport) or refuse a new connection
X chanport = DOpen(host, port#, txpri, rxpri) open a new channel
X DPri(chanport, priority) (not implemented yet)
X act = DNRead(chanport, buf, bytes) (see below)
X act = DRead(chanport, buf, bytes) (see below)
X act = DWrite(chanport, buf, bytes) act = -1 or bytes
X DEof(chanport) send eof (amiga<>amiga only)
X DQueue(chanport, maxq) set asynchronous queue write
X queue size (default 0)
X DClose(chanport) close a channel
X DUnListen(listenport) stop listening on a channel
X
X DQuit(host) cause remote end to quit out
X of the DNET protocol.
X
XGeneral notes:
X The calls have a notion of ownership. The task which created
X the listen port or openned the channel owns it. Foreign tasks
X may DAccept() connections on somebody elses listen port (i.e.
X your server creates a task to handle the accept). In fact, this
X is the only way you can spawn off tasks to handle new connections
X as only the owner of a channel (caller of DAccept()/DOpen()) may
X use the channel.
X
X The calls are not extremely efficient at the momement, but since
X the network, by virtue of being on a serial line, is so slow,
X it doesn't really matter.
X
X You are guarenteed a signal will be present whenever there is
X pending data, even if you only partially read what is available.
X NOTE that you *will* get signals sometimes even when no data is
X available, and should thus take into account DNRead() returning
X 0... Usually DNRead() is used in conjuction with Wait()ing on
X the signal bit of the channel port.
X
X DEOF()
X
X Eof a channel. Implemented ONLY for the Amiga. You cannot EOF
X a channel if running between the Amiga and a UNIX machine. This
X is essentially an unsupported call, and you should use DCLose()
X to close(and send an eof) on a channel. The network handles it
X just fine, but the UNIX side has no way of sending an EOF over
X a socket without closing the socket.
X
X DLISTEN()
X
X This call listens on a virtual port # (0-65535) for connections
X from a remote host. NULL is returned if the port is already
X being listened on by somebody else.
X
X DACCEPT()
X
X Accepts connections over a virtual port #. Several connections
X may be accepted and worked on simultaniously. NULL is returned if
X there are no pending connections. You can WaitPort() on the
X listenport to wait for new connections, but should note that
X even after a WaitPort(), DAccept() might return NULL every
X once in a while.
X
X DAccept() will set the signal bit associated with the port if
X further connections are pending.
X
X DNAACCEPT()
X
X Don't accept connections over a virtual port #. If there is a
X connection pending, it will return an error on the other end.
X Returns 1 if a connection was refused, 0 if there were no
X pending connections.
X
X DUNLISTEN()
X
X Stop listening on a virtual port #. Any pending requests are
X automatically DNAAccept()ed.
X
X DPRI()
X
X Set the priority of a channel (-128 lowest to 127 highest).
X The priority only effects throughput when two or more channels
X at different priorities are transfering data at the same time.
X
X Not currently implemented.. priority is what you set in DOpen()
X
X DNREAD()
X
X Read data from a channel. 0 is a valid return value, meaning that
X no data is currently ready to read. You can WaitPort() on the
X channel port to wait for data (or EOF). A negative value is
X returned on EOF or failure.
X
X error codes:
X -1 EOF on channel
X -2 Remote end CLOSED the channel (not implemented)
X
X DREAD()
X
X Read data from a channel. The number of bytes requested are
X returned, unless the other end closed it's side in which case
X fewer than the number of bytes requested will be returned. That
X is, this call will BLOCK waiting for data.
X
X A negative value is returned on EOF or failure.
X
X
X DWRITE()
X
X Write data to a channel. The return value is either the # bytes
X written, or a negative error code.
X
X -1 Remote end REOF'd the channel
X -2 Remote end CLOSED the channel
X
X note: not much distinction between the two
X currently.
X
X DCLOSE()
X
X Close a channel.
X
X DOPEN()
X
X Application side OPEN().... Open a port# on a remote host. Returns
X a channel port or NULL. Two priorities are given. Each may be
X in the range (lowest) -127 to 126 (highest) inclusive. The first
X priority is for transmitting data client->server, the second
X for receiving data server->client.
X
X The host field should be NULL for now. In future versions, you
X will be able to run multiple DNET's on your Amiga and this will
X field will determine which one you are attempting to connect
X through.
X
X DQUIT()
X
X Causes DNET on the remote side to quit out. If running on a
X 4.2BSD UNIX machine, the DNET will exit. If running on another
X Amiga, the DNET will return to terminal-window mode.
X
X The host has the same definition as for DOpen().
X
X
X
END_OF_FILE
if test 5169 -ne `wc -c <'amiga/doc/dnetlib.doc'`; then
echo shar: \"'amiga/doc/dnetlib.doc'\" unpacked with wrong size!
fi
# end of 'amiga/doc/dnetlib.doc'
fi
if test -f 'amiga/doshand/dos.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/doshand/dos.h'\"
else
echo shar: Extracting \"'amiga/doshand/dos.h'\" \(3671 characters\)
sed "s/^X//" >'amiga/doshand/dos.h' <<'END_OF_FILE'
X
X/*
X * DOS.H
X */
X
X#include <exec/types.h>
X#include <local/xmisc.h>
X#include <libraries/dos.h>
X#include <libraries/dosextens.h>
X#include <libraries/filehandler.h>
X
X#include <stdio.h>
X
X#include "/dnet/dnet.h"
X#include "/server/servers.h"
X#include "/dnet/channel.h"
X#include "/lib/dnetlib.h"
X
X#include <stdlib.h>
X#include <string.h>
X
X/*
X * ACTIONS which do not exist in dosextens.h but which indeed exist on
X * the Amiga.
X */
X
X#define ACTION_OPENRW 1004
X#define ACTION_OPENOLD 1005
X#define ACTION_OPENNEW 1006
X#define ACTION_CLOSE 1007
X#define ACTION_SEEK 1008
X#define ACTION_RAWMODE 994
X#define ACTION_MORECACHE 18
X#define ACTION_FLUSH 27
X
X#define DOS_FALSE 0
X#define DOS_TRUE -1
X
Xtypedef struct DosPacket PACKET;
Xtypedef struct DeviceNode DEVNODE;
Xtypedef struct DeviceList DEVLIST;
Xtypedef struct DosInfo DOSINFO;
Xtypedef struct RootNode ROOTNODE;
Xtypedef struct FileHandle FH;
Xtypedef struct DateStamp STAMP;
Xtypedef struct InfoData INFODATA;
Xtypedef struct DosLibrary DOSLIB;
Xtypedef struct FileLock LOCK;
Xtypedef struct FileInfoBlock FIB;
Xtypedef struct Library LIB;
X
X#define FILE_DIR 1
X#define FILE_FILE -1
X
X#define LOCKLINK struct _LOCKLINK
X#define HANDLE struct _HANDLE
X
X/*
X * We use this structure to link locks together in a list for internal
X * usage. I could have use the link field in the lock structure as a
X * real linked list, but didn't want to have to sequentially search the
X * list to remove a node.
X *
X * NOTE: You CANNOT simply extend the FileLock (LOCK) structure. Some
X * programs assume it is sizeof(LOCK) big and break. I found this out the
X * hard way.
X */
X
XLOCKLINK {
X NODE Node;
X LOCK *Lock;
X};
X
X/*
X * OPERATION STRUCTURES
X */
X
Xtypedef struct {
X long DirHandle; /* relative to directory (0=root) */
X uword Modes; /* open modes */
X} OpOpen;
X
Xtypedef struct {
X long Handle;
X ulong Prot;
X long Type;
X long Size;
X STAMP Date; /* date stamp */
X} RtOpen;
X
X
Xtypedef struct {
X long Handle; /* file handle to read from */
X long Bytes; /* # of bytes to read */
X} OpRead;
X
Xtypedef struct {
X long Bytes; /* < 0 == error */
X} RtRead;
X
Xtypedef struct {
X long Handle; /* file handle to read from */
X long Bytes; /* # of bytes to read */
X} OpWrite;
X
Xtypedef struct {
X long Bytes; /* < 0 == error */
X} RtWrite;
X
Xtypedef struct {
X long Handle;
X} OpClose;
X
Xtypedef struct {
X long Handle;
X long Offset;
X long How;
X} OpSeek;
X
Xtypedef struct {
X long OldOffset;
X long NewOffset; /* -1 = error */
X} RtSeek;
X
Xtypedef struct {
X long Handle;
X} OpParent;
X
Xtypedef RtOpen RtParent;
X
Xtypedef struct {
X long DirHandle;
X} OpDelete;
X
Xtypedef struct {
X long Error;
X} RtDelete;
X
Xtypedef OpDelete OpCreateDir;
Xtypedef RtParent RtCreateDir;
X
Xtypedef struct {
X long Handle;
X} OpDup;
X
Xtypedef RtOpen RtDup;
X
Xtypedef struct {
X long Handle; /* oops, actually a directory handle */
X long Index;
X} OpNextDir;
X
Xtypedef RtOpen RtNextDir;
X
Xtypedef struct {
X long DirHandle1;
X long DirHandle2;
X} OpRename;
X
Xtypedef struct {
X long Error;
X} RtRename;
X
X/*
X * Filehandle structure associated with an open file handle
X */
X
X
X#define MAGIC 0x1AFB439C
X
XHANDLE {
X NODE Node; /* link node */
X long Magic;
X LOCK *Lock; /* lock if any */
X long Handle; /* remote handle */
X short Type; /* file type */
X ulong Prot; /* protection bits */
X ulong Size; /* file size */
X STAMP Date; /* date stamp */
X char *Name; /* file name */
X};
X
END_OF_FILE
if test 3671 -ne `wc -c <'amiga/doshand/dos.h'`; then
echo shar: \"'amiga/doshand/dos.h'\" unpacked with wrong size!
fi
# end of 'amiga/doshand/dos.h'
fi
if test -f 'amiga/server/scopy.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/server/scopy.c'\"
else
echo shar: Extracting \"'amiga/server/scopy.c'\" \(4424 characters\)
sed "s/^X//" >'amiga/server/scopy.c' <<'END_OF_FILE'
X
X/*
X * SCOPY.C V1.1
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * COPY SERVER FOR PUTFILES (DOWNLOADS, i.e. receives files)
X *
X * The current version only accepts one connection at a time. This server
X * handles downloading of data. This server will eventually be replaced
X * by the SGCOPY server. Currently the SGCOPY server only handles
X * uploads.
X *
X * NOTE: The DNET_WRITE enviroment variable must be 9 or higher or this
X * server will refuse connections.
X *
X * Receive:
X * 'V' NLEN NAME FILELEN -receive compressed file (V1.1)
X * 'W' NLEN NAME FILELEN -receive file
X * 'X' NLEN NAME 0 -create and CD into directory
X * 'Y' 0 0 -restore previous directory
X * 'C' NLEN NAME 0 -set destination directory
X *
X * length in 68000 longword format.
X */
X
X#include "defs.h"
X
Xchar Buf[8192];
Xchar Buf2[8192];
X
Xint putdir ARGS((void *, char *));
Xint putfile ARGS((void *, char *, int));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
X#ifdef LATTICE
X_main(str)
X#else
X_main(len,str)
X#endif
Xchar *str;
X{
X struct MsgPort *port;
X PROC *myproc = (PROC *)FindTask(NULL);
X void *chan;
X long savedir;
X long mask, rmask;
X
X onbreak(brk);
X
X if (strncmp(str, "__dnet", 6) != 0) {
X Version("SCopy", VERSION, SCOPY_VERSION);
X _exit(0);
X }
X
X port = DListen(PORT_FILECOPY);
X {
X struct Message *msg;
X char *dir;
X
X WaitPort(&myproc->pr_MsgPort);
X msg = GetMsg(&myproc->pr_MsgPort);
X dir = (msg->mn_Node.ln_Name) ? msg->mn_Node.ln_Name : "";
X savedir = Lock(dir, SHARED_LOCK); /* duplicate current dir */
X ReplyMsg(msg);
X }
X if (!savedir) {
X DUnListen(port);
X _exit(1);
X }
X savedir = CurrentDir(savedir); /* CD dup, returns original */
X mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
X for (;;) {
X long dupdir = DupLock(myproc->pr_CurrentDir);
X rmask = Wait(mask);
X if (rmask & SIGBREAKF_CTRL_C) {
X UnLock(CurrentDir(dupdir));
X break;
X }
X while (chan = DAccept(port)) {
X if (GetEnvVal(DNET_WRITE) >= 9)
X putdir(chan, "");
X else
X DWrite(chan, "S", 1);
X DClose(chan);
X }
X UnLock(CurrentDir(dupdir));
X }
X UnLock(CurrentDir(savedir)); /* restore original */
X DUnListen(port);
X}
X
Xstatic char Name[128];
X
Xint
Xputdir(chan, dirname)
Xvoid *chan;
Xchar *dirname;
X{
X FIB *fib;
X long lock;
X long oldlock;
X long len;
X int ret = -1;
X unsigned char co, nl, rc;
X
X fib = (FIB *)AllocMem(sizeof(FIB), MEMF_PUBLIC);
X if ((lock = Lock(dirname, SHARED_LOCK)) == NULL) {
X if (lock = CreateDir(dirname)) {
X UnLock(lock);
X lock = Lock(dirname, SHARED_LOCK);
X }
X }
X if (lock == NULL || !Examine(lock,fib) || fib->fib_DirEntryType < 0) {
X if (lock)
X UnLock(lock);
X rc = 'N';
X DWrite(chan, &rc, 1);
X FreeMem(fib, sizeof(FIB));
X return(1);
X }
X rc = 'Y';
X DWrite(chan, &rc, 1);
X oldlock = CurrentDir(lock);
X while (DRead(chan, &co, 1) == 1) {
X if (DRead(chan, &nl, 1) != 1 || DRead(chan, Name, nl) != nl)
X break;
X if (DRead(chan, &len, 4) != 4)
X break;
X switch(co) {
X case 'C':
X {
X char co = 'N';
X long lock = Lock(Name, SHARED_LOCK); /* CD to dir */
X if (!lock) {
X if (lock = CreateDir(Name)) { /* or create */
X UnLock(lock);
X lock = Lock(Name, SHARED_LOCK);
X }
X }
X if (lock) {
X co = 'Y';
X UnLock(CurrentDir(lock));
X }
X DWrite(chan, &co, 1);
X }
X break;
X case 'W':
X if (putfile(chan, Name, len) < 0) {
X ret = -1;
X goto fail;
X }
X break;
X case 'X':
X if (putdir(chan, Name) < 0) {
X ret = -1;
X goto fail;
X }
X break;
X case 'Y':
X ret = 1;
X co = 'Y';
X DWrite(chan, &co, 1);
X goto fail;
X default:
X co = 'N';
X DWrite(chan, &co, 1);
X break;
X }
X }
Xfail:
X UnLock(CurrentDir(oldlock));
X FreeMem(fib, sizeof(FIB));
X return(ret);
X}
X
Xint
Xputfile(chan, name, len)
Xvoid *chan;
Xchar *name;
Xint len;
X{
X long fh = Open(name, 1006);
X long n, r;
X char rc;
X
X if (fh == NULL) {
X rc = 'N';
X DWrite(chan, &rc, 1);
X return(0);
X }
X rc = 'Y';
X DWrite(chan, &rc, 1);
X while (len) {
X r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
X n = DRead(chan, Buf, r);
X if (n != r)
X break;
X if (Write(fh, Buf, n) != n)
X break;
X len -= n;
X }
X Close(fh);
X if (len) {
X unlink(name);
X return(-1);
X }
X rc = 'Y';
X DWrite(chan, &rc, 1);
X return(0);
X}
X
END_OF_FILE
if test 4424 -ne `wc -c <'amiga/server/scopy.c'`; then
echo shar: \"'amiga/server/scopy.c'\" unpacked with wrong size!
fi
# end of 'amiga/server/scopy.c'
fi
if test -f 'unix/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/README'\"
else
echo shar: Extracting \"'unix/README'\" \(5174 characters\)
sed "s/^X//" >'unix/README' <<'END_OF_FILE'
X
X
X DNET V2.10 UNIX SIDE
X
X BSD4.2/4.3 compatible
X
X Special note this release: default is to run in 7 bit mode (which
X uses a special 6 bit encoding to encode binary data). The -m0
X option has been added for those who can run over full 8 bit nets.
X
X DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved
X
X Matthew Dillon
X 891 Regal Rd
X Berkeley, Ca. 94708
X USA
X
X ...!ihnp4!ucbvax!dillon USENET
X dillon@ucbvax.Berkeley.edu ARPANET
X ucbvax.berkeley.edu pub/amiga ARPANET-FTP
X
X UNIX SETUP
X
X The directory structure must remain intact. simply say MAKE
X in the main directory and it ought to compile. There might be
X minor problems depending on how compatible your UNIX is with
X BSD4.3 UNIX .. I have successfully compiled DNet on the following
X machines:
X
X Dec Vax 7xx
X Sun 3
X Sequent
X
X (1) Create a directory. For example, ~/.DNET WARNING! This
X directory must be on a local partition. DNET uses a unix
X domain socket and these do not work over network fileservers.
X
X (2) Modify your .cshrc to add the following line:
X
X setenv DNETDIR ~/.DNET/
X
X (or wherever you put it. NOTE! You MUST HAVE THE TRAILING
X SLASH!)
X
X (3) All binaries are usually kept in dnet.unix/bin, add this
X directory to your path (in your .cshrc) so DNet can find
X the clients.
X
X (4) Place the file 'dnet.servers' in $DNETDIR. Modify the file
X according to your home directory and where you have put the
X servers (usually in dnet.unix/bin). USE ABSOLUTE PATHS,
X DNET.SERVERS DOES NOT UNDERSTAND ~.
X
X NOTE: You may want to chmod $DNETDIR 700 to disallow any
X unauthorized access to the network.
X
X
X DIALING UP FROM AN AMIGA
X
X Follow the installation instructions for the Amiga side. When
X you dial up the UNIX system you will eventually get a prompt.
X NOTE! DNET normally uses 7 bit - even parity for dialing up,
X then switches to 8 bit no parity for the protocol. Sometimes
X the modem or port selector will switch into 7 bit + parity mode
X and NOT SWITCH OUT. For this reason, you might want to use the
X -8 option for the Amiga side of DNET (read the docs in the Amiga
X section).
X
X You may have to force parity before running DNet. To force parity
X to even use (and do this only if running the -Z2 option from the
X Amiga side dnet): THIS IS NOT NORMALLY DONE.
X
X % stty -odd
X
X From the DNET window's CSH prompt, start the protocol with:
X
X % dnet
X
X That was easy. The DNet window should go away and an FTERM window
X should open. This does not mean success! If the FTERM window
X closes again with the message "unable to connect", it was unable
X to connect. There are several possibilities:
X
X (a) You do not have an 8 bit connection from your amiga to the
X UNIX host (DNet must be able to send and receive all 256
X character codes).
X
X (b) You did not setup the DNETDIR enviroment variable properly
X
X (c) You did not copy dnet.servers into $DNETIDR
X
X (d) The absolute file path in dnet.servers for server #8192 (that
X FTerm tires to connect to) is not correct.
X
X KILLING DNET
X
X In most cases simply turning off the modem will suffice. You can
X kill dnet more cleanly with the following sequence:
X
X (1) From an Amiga CLI, run the QuitDnet command. This will kill
X the packet protocol and cause the remote DNet to exit. It
X will then break the local DNet.
X
X You should get the original (small) DNet window and the
X original login shell. If you get the DNet window but not the
X shell (you can't type), the protocol may still be running on
X the other end, in which case it didn't work for some unknown
X reason. Restart the protocol w/ the appropriate menu option
X and try 'quitdnet' again.
X
X (3) logout normally and close the DNet window. Turn off your
X modem.
X
X If the kill sequence in (2) does not work, you can simply
X hangup the line.
X
X HANGING SERVER PROCESSES
X
X The UNIX side servers are normally left running when the protocol
X dies. These are very very very small and take 0 CPU (they are
X simply waiting for connections). These servers will still be
X there when you log in again and DNet will use them.
X
X You can kill UNIX side servers at any time.
X
X Many of the same clients and servers exist on the UNIX end as
X on the Amiga end. The UNIX end is missing several. The UNIX
X end implements two commands called dsoc and draw which can be
X used to connect to (in cooked or raw tty mode) specific servers
X (by port #) on the Amiga side. For example, to connect to the
X printer server on the amiga side:
X
X % dsoc 8198
X This is a test
X ^D
X %
X
X Dumps to PRT: on the Amiga "This is a test" Gee Wiz!
X
X SECURITY W/ UNIX
X
X DNet will be as secure as your account, assuming you chmod DNETDIR
X 700 (so nobody else has access to the unix domain sockets). From
X Home (on the Amiga), I usually RUN DNET -X , login, start the
X protocol, and leave it running all day.
X
X The -X option turns of security (sets all security levels to 9),
X thus allowing me to drive to the university and at any time from
X my UNIX account do a getfiles or putfiles from and to my Amiga.
X
X Refer to the amiga side documentation for more information.
X
X
X
END_OF_FILE
if test 5174 -ne `wc -c <'unix/README'`; then
echo shar: \"'unix/README'\" unpacked with wrong size!
fi
# end of 'unix/README'
fi
if test -f 'unix/client/putfiles.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/client/putfiles.c'\"
else
echo shar: Extracting \"'unix/client/putfiles.c'\" \(3756 characters\)
sed "s/^X//" >'unix/client/putfiles.c' <<'END_OF_FILE'
X
X/*
X * PUTFILES.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Download one or more files from the remote computer
X *
X * PUTFILES file/dir1 file/dir2 ... file/dirN
X *
X * placed in directory server ran from on remote host.
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/dir.h>
X#include <stdio.h>
X#include <sys/file.h>
X#include "../server/servers.h"
X
Xchar Buf[1024];
X
Xtypedef struct stat STAT;
X
Xmain(ac,av)
Xchar *av[];
X{
X long chan;
X long n, len, orig;
X long fh;
X short i, j;
X char fn;
X
X if (ac == 1) {
X puts("putfiles V1.00 (c)Copyright 1987, Matthew Dillon, All Rights Reserved");
X puts("putfiles file/dir file/dir .....");
X exit(1);
X }
X
X chan = DOpen(NULL, PORT_FILECOPY, -80, 126);
X if (chan < 0) {
X puts("Unable to connect");
X exit(1);
X }
X ggread(chan, &fn, 1);
X if (fn != 'Y') {
X puts("Remote Server Software Error");
X close(chan);
X }
X for (i = 1; i < ac; ++i) {
X if (strncmp(av[i], "-d", 2) == 0) {/*-ddir or -d dir*/
X char *dir = av[i]+2;
X if (*dir == 0 && i+1 < ac) {
X ++i;
X dir = av[i];
X }
X if (writehdr_nc(chan, 'C', dir, 0) != 'Y') {
X puts ("unable to go to specified remote directory");
X break;
X }
X } else {
X if (putname(chan, av[i]) < 0)
X break;
X }
X }
X printf("\nclosing... ");
X fflush(stdout);
X close(chan);
X puts("done");
X}
X
Xputname(chan, file)
Xchar *file;
X{
X STAT sstat;
X char svdir[256];
X int ret;
X
X printf("%-20s ", file);
X if (stat(file, &sstat) < 0) {
X puts("NOT FOUND");
X return(1);
X }
X if (sstat.st_mode & S_IFDIR) {
X DIR *dir;
X struct direct *de;
X
X getwd(svdir);
X puts("DIR");
X chdir(file);
X if (writehdr(chan, 'X', file, 0) != 'Y') {
X puts("Remote unable to make directory");
X goto f1;
X }
X if (dir = opendir(".")) {
X while (de = readdir(dir)) {
X if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name,"..")==0)
X continue;
X if (putname(chan, de->d_name) < 0) {
X ret = -1;
X break;
X }
X }
X }
X writehdr(chan, 'Y', "?", 0);
Xf1:
X chdir(svdir);
X } else {
X ret = putfile(chan, file);
X }
X return(ret);
X}
X
Xputfile(chan, file)
Xchar *file;
X{
X int fd = open(file, O_RDONLY);
X long n, r, len;
X long ttl = 0;
X char co;
X
X fflush(stdout);
X if (fd < 0) {
X puts("FILE NOT FOUND");
X return(0);
X }
X len = ttl = lseek(fd, 0, 2);
X lseek(fd, 0, 0);
X if (writehdr(chan, 'W', file, len) != 'Y') {
X puts("REMOTE UNABLE TO ACCEPT FILE");
X close(fd);
X return(0);
X }
X printf("%6ld/%-6ld", ttl - len, ttl);
X while (len) {
X fflush(stdout);
X r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
X n = read(fd, Buf, r);
X if (n != r) {
X puts("Local File error");
X close(fd);
X return(-1);
X }
X if (gwrite(chan, Buf, n) != n) {
X puts("Remote error");
X close(fd);
X return(-1);
X }
X len -= n;
X printf("\010\010\010\010\010\010\010\010\010\010\010\010\010");
X printf("%6ld/%-6ld", ttl - len, ttl);
X }
X close(fd);
X if (len) {
X puts("REMOTE ERROR");
X return(-1);
X }
X printf(" Queued, waiting... ");
X fflush(stdout);
X ggread(chan, &co, 1);
X if (co != 'Y') {
X puts("Remote Server Software Error");
X return(-1);
X }
X puts("OK");
X return(0);
X}
X
Xwritehdr(chan, c, name, len)
Xunsigned char c;
Xchar *name;
Xlong len;
X{
X short i;
X for (i = strlen(name) - 1; i >= 0; --i) {
X if (name[i] == '/' || name[i] == ':')
X break;
X }
X name += i + 1;
X return(writehdr_nc(chan, c, name, len));
X}
X
Xwritehdr_nc(chan, c, name, len)
Xunsigned char c;
Xchar *name;
Xlong len;
X{
X gwrite(chan, &c, 1);
X c = strlen(name) + 1;
X gwrite(chan, &c, 1);
X gwrite(chan, name, c);
X len = htonl68(len);
X gwrite(chan, &len, 4);
X if (ggread(chan, &c, 1) == 1)
X return(c);
X return(-1);
X}
X
END_OF_FILE
if test 3756 -ne `wc -c <'unix/client/putfiles.c'`; then
echo shar: \"'unix/client/putfiles.c'\" unpacked with wrong size!
fi
# end of 'unix/client/putfiles.c'
fi
if test -f 'unix/dnet/internal.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/internal.c'\"
else
echo shar: Extracting \"'unix/dnet/internal.c'\" \(4223 characters\)
sed "s/^X//" >'unix/dnet/internal.c' <<'END_OF_FILE'
X
X/*
X * INTERNAL.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Usually SCMD_OPEN requests attempt to connect() to the UNIX
X * domain socket of the server. However, some 'ports' are designated
X * as internal to DNET. They reside here.
X *
X * -IALPHATERM
X */
X
X#include "dnet.h"
X#include "../server/servers.h"
X#include <sys/stat.h>
X#include <sys/wait.h>
X#include <sys/resource.h>
X#include <sys/uio.h>
X#include <strings.h>
X
Xextern char *getenv();
X
Xisinternalport(port)
Xuword port;
X{
X if (port == PORT_IALPHATERM)
X return(1);
X return(0);
X}
X
Xiconnect(ps, port)
Xint *ps;
Xuword port;
X{
X if (port == PORT_IALPHATERM)
X return(ialphaterm_connect(ps, port));
X return(-1);
X}
X
Xialphaterm_connect(pmaster)
Xint *pmaster;
X{
X struct sgttyb sg;
X struct tchars tc;
X struct ltchars ltc;
X#ifdef TIOCGSIZE
X struct ttysize ts;
X#else
X#ifdef TIOCGWINSZ
X struct winsize ws;
X#endif
X#endif
X int lmode;
X int fdmaster;
X int fdslave;
X int pid;
X char *slavename;
X
X ioctl(0, TIOCGETP, (char *)&sg);
X ioctl(0, TIOCGETC, (char *)&tc);
X ioctl(0, TIOCGLTC, (char *)<c);
X ioctl(0, TIOCLGET, (char *)&lmode);
X#ifdef TIOCGSIZE
X ioctl(0, TIOCGSIZE, &ts);
X#else
X#ifdef TIOCGWINSZ
X ioctl(0, TIOCGWINSZ, &ws);
X#endif
X#endif
X
X sg.sg_flags &= ~(RAW);
X sg.sg_flags |= ECHO;
X#ifdef TIOCGSIZE
X ts.ts_lines = 23;
X ts.ts_cols = 77;
X#else
X#ifdef TIOCGWINSZ
X ws.ws_row = 23;
X ws.ws_col = 77;
X#endif
X#endif
X
X if (DDebug)
X fprintf(stderr, "PTY openning internal pty\n");
X if (openpty(&fdmaster, &fdslave, &slavename) >= 0) {
X if (DDebug)
X fprintf(stderr, "PTY open successfull\n");
X if ((pid = fork()) == NULL) {
X int i;
X setenv("DNET=", "IALPHATERM");
X setuid(getuid());
X signal(SIGHUP, SIG_DFL);
X signal(SIGINT, SIG_DFL);
X signal(SIGQUIT, SIG_DFL);
X signal(SIGTERM, SIG_DFL);
X signal(SIGCHLD, SIG_DFL);
X signal(SIGTSTP, SIG_IGN);
X ioctl(open("/dev/tty", 2), TIOCNOTTY, NULL);
X close(open(slavename, 0));
X dup2(fdslave, 0);
X dup2(0, 1);
X dup2(0, 2);
X for (i = 3; i < 256; ++i)
X close(i);
X ioctl(0, TIOCSETN, &sg);
X ioctl(0, TIOCSETC, &tc);
X ioctl(0, TIOCSLTC, <c);
X ioctl(0, TIOCLSET, &lmode);
X#ifdef TIOCSSIZE
X ioctl(0, TIOCSSIZE, &ts);
X#else
X#ifdef TIOCSWINSZ
X ioctl(0, TIOCSWINSZ, &ws);
X#endif
X#endif
X {
X char *shell = getenv("SHELL");
X char *home = getenv("HOME");
X if (!shell)
X shell = "/bin/sh";
X if (!home)
X home = ".";
X chdir(home);
X execl(shell, "-fshell", NULL);
X perror(shell);
X }
X _exit(1);
X }
X if (pid > 0) {
X *pmaster = fdmaster;
X close(fdslave);
X if (DDebug)
X fprintf(stderr, "PTY OPEN OK.2\n");
X return(1);
X }
X close(fdmaster);
X close(fdslave);
X if (DDebug)
X fprintf(stderr, "PTY OPEN FAILURE.1\n");
X }
X if (DDebug)
X fprintf(stderr, "PTY OPEN FAILURE.2\n");
X return(-1);
X}
X
Xopenpty(pfdm, pfds, pnames)
Xint *pfdm;
Xint *pfds;
Xchar **pnames;
X{
X static char ptcs[] = { "0123456789abcdef" };
X static char plate[] = { "/dev/ptyxx" };
X struct stat stat;
X int i;
X int j;
X
X for (i = 'p';; ++i) {
X plate[8] = i;
X plate[9] = ptcs[0];
X if (lstat(plate, &stat) < 0)
X break;
X for (j = 0; ptcs[j]; ++j) {
X plate[9] = ptcs[j];
X plate[5] = 'p';
X if ((*pfdm = open(plate, O_RDWR)) >= 0) {
X plate[5] = 't';
X if ((*pfds = open(plate, O_RDWR)) >= 0) {
X *pnames = plate;
X if (DDebug)
X fprintf(stderr, "PTY FOUND %s\n", *pnames);
X return(1);
X }
X close(*pfdm);
X }
X }
X }
X return(-1);
X}
X
Xisetrows(fd, rows)
X{
X#ifdef TIOCSSIZE
X struct ttysize ts;
X if (ioctl(fd, TIOCGSIZE, &ts) >= 0) {
X ts.ts_lines = rows;
X ioctl(fd, TIOCSSIZE, &ts);
X }
X#else
X#ifdef TIOCSWINSZ
X struct winsize ws;
X if (ioctl(fd, TIOCGWINSZ, &ws) >= 0) {
X ws.ws_row = rows;
X ioctl(fd, TIOCSWINSZ, &ws);
X }
X#endif
X#endif
X}
X
Xisetcols(fd, cols)
X{
X#ifdef TIOCSSIZE
X struct ttysize ts;
X if (ioctl(fd, TIOCGSIZE, &ts) >= 0) {
X ts.ts_cols = cols;
X ioctl(fd, TIOCSSIZE, &ts);
X }
X#else
X#ifdef TIOCSWINSZ
X struct winsize ws;
X if (ioctl(fd, TIOCGWINSZ, &ws) >= 0) {
X ws.ws_col = cols;
X ioctl(fd, TIOCSWINSZ, &ws);
X }
X#endif
X#endif
X}
X
END_OF_FILE
if test 4223 -ne `wc -c <'unix/dnet/internal.c'`; then
echo shar: \"'unix/dnet/internal.c'\" unpacked with wrong size!
fi
# end of 'unix/dnet/internal.c'
fi
if test -f 'unix/doc/dnetlib.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/doc/dnetlib.doc'\"
else
echo shar: Extracting \"'unix/doc/dnetlib.doc'\" \(3568 characters\)
sed "s/^X//" >'unix/doc/dnetlib.doc' <<'END_OF_FILE'
X
XUNIX/DNETLIB
X
X UNIX END DNET LIBRARY INTERFACE
X
X See the server source for good examples of usage.
X
Xlong private;
Xuword port
Xchar *buf;
Xint fd;
Xint res1..5, bytes
Xchar pri;
Xlong val68, valvax;
X
Xprivate = DListen(port) listen on a port (server)
X fd = DAccept(private) accept a connection (server)
X DNAAccept(private) don't accept a conn.(server)
X fd = DOpen(host, port, txpri, rxpri) open a remote connection (client)
X res1 = read(fd, buf, bytes) standard unix read()
X res2 = gread(fd, buf, bytes) (see below)
X res3 = ggread(fd, buf, bytes) (see below)
X res4 = write(fd, buf, bytes) standard unix write()
X res5 = gwrite(fd, buf, bytes) (see below)
X close(fd);
X
X val68 = ntohl68(valvax) convert to and from MC68000 longword format.
X valvax= htonl68(val68)
X
X
XDListen() sets up a UNIX domain socket in the current directory unless
X another is specified by the DNETDIR enviroment variable.
X Returns a private structure pointer or NULL on error.
X
X This call will override any existing server for the port in
X the directory permanently. It does not cause an existing
X server to exit, however, and you should be careful to kill
X old servers before starting new ones. See the source for a
X template of correct server code.
X
XDAccept() Accepts a new connection on the port. Returns a file
X descriptor or a negative value. This call will block.
X
XDOpen() Attempt to connect to a port on the remote machine. Returns
X a file descriptor or a negative value. The error is either
X due to not finding DNET's master port (DNET must be running),
X or the remote server not running.
X
X This call looks in the current directory for the master
X socket unless another is specified by the DNETDIR enviroment
X variable.
X
X Two priorities are specified. One for sending, and one for
X receiving data. A priority is a value -127 to 126 inclusive,
X with 126 the highest priority. Normally, priorities range
X from -80 (file transfers) to +20 (terminal window).
X
XDEof() Send an EOF without closing the connection. Currently doesn't
X work worth shit, so don't use it.
X
Xwrite() Standard UNIX write call. But we are dealing with a socket
X here, so one must be careful of the return value. (1) WRITE()
X may not return the # bytes requested to write, but less,
X (2) WRITE() may return a negative value indicating an error or
X that it was interrupted or that it would have blocked (if you
X have got non-blocking IO setup). (3) WRITE() returns 0 on
X socket EOF.
X
Xgwrite() This call will write all the bytes specified, whether the
X socket is non-blocking or not. It handles restarting the
X WRITE() call on EINTR and properly handles EWOULDBLOCK.
X
X It returns the number bytes requested or fewer on error. If
X fewer bytes are returned you should close the socket and exit.
X
Xread() Standard UNIX read call. But we are still dealing with a
X socket here and anything might happen. READ() can return fewer
X than the number of bytes requested, 0 on EOF, or a negative
X number indicating various errors.
X
Xgread() GREAD() handles retrying if the EINTR error occurs. GREAD()
X blocks until at least one character is received (or EOF), and
X does this even if the socket is marked non-blocking. GREAD()
X returns 0 on EOF/ERROR.
X
Xggread() GGREAD() not only retries on EINTR, but will block until ALL
X the requested bytes are read in, even if the socket is marked
X non-blocking. GGREAD() returns -1 on EOF/ERROR. You can also
X tell if an EOF/ERROR occured if fewer than the requested
X number of bytes are read.
X
END_OF_FILE
if test 3568 -ne `wc -c <'unix/doc/dnetlib.doc'`; then
echo shar: \"'unix/doc/dnetlib.doc'\" unpacked with wrong size!
fi
# end of 'unix/doc/dnetlib.doc'
fi
if test -f 'unix/server/sgcopy.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/server/sgcopy.c'\"
else
echo shar: Extracting \"'unix/server/sgcopy.c'\" \(5462 characters\)
sed "s/^X//" >'unix/server/sgcopy.c' <<'END_OF_FILE'
X
X/*
X * SGCOPY.C V1.1
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * GET-COPY SERVER (NEW COPY SERVER)
X *
X * The current version only accepts one connection at a time. This server
X * will send requested files to the remote machine.
X *
X * length in 68000 longword format.
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/wait.h>
X#include <sys/time.h>
X#include <sys/dir.h>
X#include <sys/file.h>
X#include <sys/resource.h>
X#include <stdio.h>
X#include <errno.h>
X#include <signal.h>
X
X#include "servers.h"
X
Xtypedef struct {
X char Cmd;
X char Str[64];
X long Val;
X} HDR;
X
Xtypedef unsigned char ubyte;
Xchar *getnamepart();
Xchar *getdirpart();
X
Xchar Buf[4096];
Xint Chan;
X
Xchandler()
X{
X union wait stat;
X struct rusage rus;
X while (wait3(&stat, WNOHANG, &rus) > 0);
X}
X
Xmain(ac,av)
Xchar *av[];
X{
X long chann = DListen(PORT_GFILECOPY);
X int fd;
X int n;
X char buf[256];
X extern int errno;
X
X if (av[1])
X chdir(av[1]);
X signal(SIGCHLD, chandler);
X signal(SIGPIPE, SIG_IGN);
X for (;;) {
X fd = DAccept(chann);
X if (fd < 0) {
X if (errno == EINTR)
X continue;
X break;
X }
X if (fork() == NULL) {
X SGCopy(fd);
X _exit(1);
X }
X close(fd);
X }
X perror("SCOPY");
X}
X
XSGCopy(fd)
Xint fd;
X{
X short error = 0;
X static HDR Hdr;
X
X Chan = fd;
X error = WriteHeader('H', "Hello, GCopy server V1.30", 0);
X if (error)
X return(error);
X switch(ReadHeader(&Hdr)) {
X default:
X case -1:
X error = 1;
X return(error);
X case 'H':
X break;
X }
X while (!error) {
X switch(ReadHeader(&Hdr)) {
X case 'G':
X {
X char svdir[1024];
X getwd(svdir);
X if (chdir(getdirpart(Hdr.Str)) < 0) {
X error = WriteHeader('N', "Unable to cd to dir", 0);
X } else {
X error = PutObject(getnamepart(Hdr.Str));
X }
X chdir(svdir);
X }
X break;
X case 'E':
X goto done;
X case 'P': /* put-files, not implemented */
X default:
X error = 1;
X break;
X }
X }
Xdone:
X ;
X}
X
XPutObject(str)
Xchar *str;
X{
X struct stat stat;
X short error = 0;
X
X if (lstat(str, &stat) < 0) {
X error = WriteHeader('N', "Unable to find object", 0);
X return(0);
X }
X if (stat.st_mode & S_IFDIR) {
X error = PutDir(str);
X } else {
X error = PutFile(str);
X }
X return(0);
X}
X
XPutDir(name)
Xchar *name;
X{
X struct stat stat;
X char svdir[1024];
X static HDR Hdr;
X short error = 0;
X char *fn = getnamepart(name);
X DIR *dir;
X struct direct *de;
X
X if (lstat(name, &stat) < 0 || !(dir = opendir(name))) {
X WriteHeader('N', "Possible Disk Error", 0);
X error = 1;
X goto done;
X }
X if (error = WriteHeader('D', fn, 0))
X goto done;
X switch(ReadHeader(&Hdr)) {
X case 'Y':
X break;
X case 'S':
X goto done;
X case 'N':
X error = 1;
X break;
X default:
X error = 1;
X break;
X }
X if (error)
X goto done;
X
X getwd(svdir);
X if (chdir(name) < 0) {
X error = 1;
X WriteHeader('N', "unable to chdir", 0);
X }
X if (error)
X goto done;
X
X while (de = readdir(dir)) {
X if (strcmp(de->d_name, ".") == 0)
X continue;
X if (strcmp(de->d_name, "..") == 0)
X continue;
X if (lstat(de->d_name, &stat) < 0) {
X continue;
X }
X if (stat.st_mode & S_IFDIR) {
X error = PutDir(de->d_name);
X } else {
X error = PutFile(de->d_name);
X }
X if (error)
X break;
X }
X WriteHeader('E', NULL, 0);
X chdir(svdir);
Xdone:
X return(error);
X}
X
XPutFile(name)
Xchar *name;
X{
X int fd = -1;
X static HDR Hdr;
X long len;
X short error = 0;
X char *fn = getnamepart(name);
X
X fd = open(fn, O_RDONLY, 0);
X if (fd < 0) { /* don't do anything if unable to open it */
X WriteHeader('N', "file not readable", 0);
X goto done;
X }
X len = lseek(fd, 0L, 2);
X if (error = WriteHeader('F', fn, len))
X goto done;
X switch(ReadHeader(&Hdr)) {
X case 'Y':
X lseek(fd, Hdr.Val, 0); /* start pos. */
X len -= Hdr.Val;
X if (len < 0)
X len = 0;
X break;
X case 'S':
X goto done;
X case 'N':
X error = 1;
X break;
X default:
X error = 1;
X break;
X }
X if (error)
X goto done;
X while (len) {
X register long n = (len > sizeof(Buf)) ? sizeof(Buf) : len;
X
X if (read(fd, Buf, n) != n) { /* read failed! */
X error = 10;
X goto done;
X }
X if (gwrite(Chan, Buf, n) != n) {
X error = 10;
X goto done;
X }
X len -= n;
X }
Xdone:
X if (fd >= 0)
X close(fd);
X return(error);
X}
X
X
XWriteHeader(c, str, len)
Xchar c;
Xchar *str;
Xlong len;
X{
X ubyte sl;
X
X if (str == NULL)
X str = "";
X sl = strlen(str);
X
X if (gwrite(Chan, &c, 1) < 0)
X return(1);
X if (gwrite(Chan, &sl,1) < 0)
X return(1);
X if (gwrite(Chan, str, sl) != sl)
X return(1);
X len = htonl68(len);
X if (gwrite(Chan, &len, 4) != 4)
X return(1);
X return(0);
X}
X
XReadHeader(hdr)
XHDR *hdr;
X{
X ubyte sl;
X ubyte cmd;
X
X hdr->Cmd = -1;
X if (ggread(Chan, &cmd, 1) != 1)
X return(-1);
X if (ggread(Chan, &sl, 1) != 1)
X return(-1);
X if (sl >= sizeof(hdr->Str)) {
X return(-1);
X }
X if (ggread(Chan, hdr->Str, sl) != sl)
X return(-1);
X hdr->Str[sl] = 0;
X if (ggread(Chan, &hdr->Val, 4) != 4)
X return(-1);
X hdr->Val = ntohl68(hdr->Val);
X hdr->Cmd = cmd;
X return(hdr->Cmd);
X}
X
Xchar *
Xgetnamepart(str)
Xchar *str;
X{
X register char *ptr = str + strlen(str);
X
X while (ptr >= str) {
X if (*ptr == '/')
X break;
X --ptr;
X }
X return(ptr+1);
X}
X
Xchar *
Xgetdirpart(str)
Xchar *str;
X{
X static char buf[1024];
X
X strcpy(buf, str);
X getnamepart(buf)[0] = 0;
X if (buf[0] == 0)
X return(".");
X return(buf);
X}
END_OF_FILE
if test 5462 -ne `wc -c <'unix/server/sgcopy.c'`; then
echo shar: \"'unix/server/sgcopy.c'\" unpacked with wrong size!
fi
# end of 'unix/server/sgcopy.c'
fi
echo shar: End of archive 3 \(of 8\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 8 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.